<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网页计算器</title>
    <style>
        body{

        }
    </style>
</head>
<body>

<h1>计算器</h1>
<p>
    整数一：
    <input type="text" id="clo">
</p>
<p>
    整数二：
    <input type="text" id="old">
</p>
<p>
    <button onclick="sum(1)">相加</button>
    <button onclick="sum(2)">相减</button>
    <button onclick="sum(3)">相乘</button>
    <button onclick="sum(4)">相除</button>
</p>
<p>
    结果 ：
    <input type="text" id="result">
</p>


<script>
    function sum(n) {
    	
       var clo = document.querySelector("#clo");
        clo = clo.value;
        clo = Number(clo);
       var old = document.querySelector("#old");
        old = old.value;
        old = Number(old);


        if (n==1){
            document.querySelector("#result").value = clo + old;
        }
        if (n==2){
            document.querySelector("#result").value = clo - old;
        }
        if (n==3){
            document.querySelector("#result").value = clo * old;
        }
        if (n==4){
            document.querySelector("#result").value = clo / old;
        }
    }


</script>
</body>
</html>